package com.fjec.market.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjec.market.entity.InfoBusiness;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 005.商户表 Mapper 接口
 * </p>
 *
 * @author admin
 * @since 2020-09-07
 */
public interface InfoBusinessMapper extends BaseMapper<InfoBusiness> {
    List<InfoBusiness> getBusinessByMarkIdAndBusiType(@Param("markCode") Integer markCode, @Param("busiType") int busiType, Page page);

    @SelectProvider(type = com.fjec.market.mapper.sqlbuilder.BusinessSqlBuilder.class, method = "getBusinessesByBusinessIdsAndMarkCode")
    List<InfoBusiness> getBusinessesByBusinessIdsAndMarkCode(@Param("markCode") int markCode, @Param("businessIds") List<Long> businessIds,
                                                             @Param("busiType") int busiType, Page page);

    List<InfoBusiness> getBusinessByShopNumAndMarkCode(@Param("markCode") int markCode, @Param("shopNum") Long shopNum, @Param("busiType") int busiType);

    /**
     * 获取需要生成shopNum的分拣、农资、包装列表
     *
     * @param limit
     * @param minutes
     * @return
     */
    List<Map<String, Object>> getBusinessForShopNumGen(@Param("limit") Integer limit,
                                                       @Param("minutes") Integer minutes);

    /**
     * 统计分拣、包装数据
     *
     * @param startTime
     * @param busiType
     * @return
     */
    List<Map<String, Object>> statBusinessData(@Param("startTime") LocalDateTime startTime,
                                               @Param("endTime") LocalDateTime endTime,
                                               @Param("busiType") Integer busiType);

    /**
     * 统计农资数据
     *
     * @param startTime
     * @return
     */
    List<Map<String, Object>> statMaterialData(@Param("startTime") LocalDateTime startTime,
                                               @Param("endTime") LocalDateTime endTime);


    List<Map<String, Object>> getBusinessWithMarkCodeByUserId(Long userId);

    Page<Map<String, Object>> getBusinessesOfAllTypesByConditions(Integer searchBy, String title, List<Long> ids, Integer busiType, Integer markCode, String startTime, String endTime, Page page);

    List<Map<String, Object>> getBusiNamesByBusiIdOrUserIds(@Param("busiIdOrUserIds") List<Long> busiIdOrUserIds);

    /**
     * 临时定时更新店铺排序
     *
     * @return
     */
    Long tmpUpdateWeight(@Param("num") Integer num);
}
